home *** CD-ROM | disk | FTP | other *** search
/ Treccani Italiana Di Scienze Lettere Ed Arti / [Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso / mac / data / menu_dvd.swf / scripts / __Packages / CDialogManager.as < prev    next >
Text File  |  2007-11-07  |  3KB  |  130 lines

  1. class CDialogManager extends mx.core.UIObject
  2. {
  3.    var mLoading = false;
  4.    function CDialogManager()
  5.    {
  6.       super();
  7.       this._visible = false;
  8.       this.init();
  9.    }
  10.    function init()
  11.    {
  12.       this.mEnableGrab = true;
  13.       this.mStartX = 40;
  14.       this.mStartY = 205;
  15.       this.mX = this._x;
  16.       this.mY = this._y;
  17.       this.mFile = "";
  18.       this.mFrame = "";
  19.       this.mLoading = false;
  20.       this.mc_ProgressBar._visible = false;
  21.       this.createEmptyMovieClip("content",3);
  22.       this.content._x = this.mStartX;
  23.       this.content._y = this.mStartY;
  24.       this.Show(false);
  25.       this.content.onPress = function()
  26.       {
  27.       };
  28.       this.content.useHandCursor = false;
  29.       this.mc_DialogGrabR.onPress = mx.utils.Delegate.create(this,this.onGrabClick);
  30.    }
  31.    function onGrabClick()
  32.    {
  33.       this.Show(false);
  34.    }
  35.    function LoadContents(inFile, inMarker, inModal)
  36.    {
  37.       trace("LoadContents" + inFile);
  38.       this.Show(true,inModal);
  39.       if(inFile != this.mFile)
  40.       {
  41.          if(this.mFile != "")
  42.          {
  43.             this.content.unloadMovie();
  44.          }
  45.          this.mFile = inFile;
  46.          this.mFrame = inMarker;
  47.          this.mLoading = true;
  48.          this.mc_ProgressBar._visible = true;
  49.          this.content.loadMovie(this.mFile);
  50.       }
  51.       else
  52.       {
  53.          this.mFrame = inMarker;
  54.          if(!this.mLoading)
  55.          {
  56.             this.JumpToMarker();
  57.          }
  58.       }
  59.    }
  60.    function GoMarker(inMarker)
  61.    {
  62.       if(this.mFile != "")
  63.       {
  64.          this.content.gotoAndStop(inMarker);
  65.       }
  66.    }
  67.    function onEnterFrame(inValue)
  68.    {
  69.       if(this.mLoading)
  70.       {
  71.          var bLoaded = this.content.getBytesLoaded();
  72.          var bTotal = this.content.getBytesTotal();
  73.          var factor = Math.min(bLoaded / bTotal * 100,100);
  74.          this.mc_ProgressBar.SetProgress(factor);
  75.          if(bLoaded >= bTotal && bTotal != 0)
  76.          {
  77.             trace("done");
  78.             this.mc_ProgressBar.SetProgress(100);
  79.             this.mc_ProgressBar._visible = false;
  80.             this.mLoading = false;
  81.             if(this.mFrame != "")
  82.             {
  83.                this.JumpToMarker();
  84.                this.doLater(this,"JumpToMarker");
  85.                trace("content.gotoAndStop " + this.mFrame);
  86.             }
  87.          }
  88.       }
  89.    }
  90.    function JumpToMarker()
  91.    {
  92.       trace("JumpToMarker");
  93.       if(this.mFrame == "")
  94.       {
  95.          return undefined;
  96.       }
  97.       if(this.content.VaiA)
  98.       {
  99.          this.content.VaiA(this.mFrame);
  100.       }
  101.       else
  102.       {
  103.          this.content.gotoAndStop(this.mFrame);
  104.       }
  105.    }
  106.    function Show(inTrueFalse, inModal)
  107.    {
  108.       trace("SHOW");
  109.       if(inModal == undefined)
  110.       {
  111.          inModal = true;
  112.       }
  113.       if(inTrueFalse != this.content._visible)
  114.       {
  115.          this.content._visible = inTrueFalse;
  116.       }
  117.       if(inTrueFalse)
  118.       {
  119.          this.content._x = this.mStartX;
  120.          this.content._y = this.mStartY;
  121.       }
  122.       this.mc_DialogGrabR._visible = inModal && inTrueFalse;
  123.       this._visible = inTrueFalse;
  124.    }
  125.    function onUnload()
  126.    {
  127.       this.content.removeMovieClip();
  128.    }
  129. }
  130.